﻿using System.Globalization;
using System.Windows.Data;

namespace DimensionsHelper.Client.Converters;

public class BooleanToVisibilityReversedConverter : IValueConverter, IMultiValueConverter
{
    public static BooleanToVisibilityReversedConverter Instance => new();

    public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
    {
        foreach (object val in values)
        {
            if (val is true)
            {
                return Visibility.Collapsed;
            }
        }

        return Visibility.Visible;
    }

    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
    {
        return [];
    }

    public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        return value is true ? Visibility.Collapsed : Visibility.Visible;
    }

    public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        return Binding.DoNothing;
    }
}